
package de.unihannover.se.restlab.microblog.resources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import de.unihannover.se.restlab.microblog.models.Link;
import de.unihannover.se.restlab.microblog.models.Microblog;

@Path("/")
public class MicroblogResource {
	@Context
	UriInfo ui;

	private Microblog microblog;

	public MicroblogResource () {
	}

	@GET
	@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
	public Response entry () {
		if (microblog == null) {
			microblog = new Microblog(new Link(ui.getAbsolutePathBuilder().build() + "messages/", "messages"), new Link(ui
				.getAbsolutePathBuilder().build() + "users/", "users"), new Link(ui.getAbsolutePathBuilder().build() + "accounts/",
				"accounts"));
		}

		return Response.ok(microblog).build();
	}

}
